package com.xindacloud.sms.console.system.controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xindacloud.sms.console.constant.SessionKeys;
import com.xindacloud.sms.console.result.Result;
import com.xindacloud.sms.console.system.dto.SmsSystemMenuDTO;
import com.xindacloud.sms.console.system.entity.SmsSystemMenu;
import com.xindacloud.sms.console.system.entity.SmsUser;
import com.xindacloud.sms.console.system.service.ISmsSystemMenuService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * <p>
 * 菜单表 前端控制器
 * </p>
 *
 * @author czc
 * @since 2019-10-08
 */
@Api(tags = {"系统菜单模块"})
@RestController
@RequestMapping("/api/v1/sms-system-menu")
public class SmsSystemMenuController {

	@Autowired
	private ISmsSystemMenuService smsSystemMenuService;
	
	@ApiOperation(value = "获取系统菜单列表",response=SmsSystemMenu.class)
	@PostMapping(value = "/getSmsSystemMenuList")
	public Result getSmsSystemMenuList(@RequestBody SmsSystemMenuDTO smsSystemMenuDTO) {
	    return smsSystemMenuService.getSmsSystemMenuList(smsSystemMenuDTO);
	}
	
	@ApiOperation(value = "保存或修改系统菜单")
	@PostMapping(value = "/saveOrUpdateSmsSystemMenu")
	public Result saveOrUpdateSmsSystemMenu(@RequestBody SmsSystemMenuDTO smsSystemMenuDTO) {
	    return smsSystemMenuService.saveOrUpdateSmsSystemMenu(smsSystemMenuDTO);
	}
	
	@ApiOperation(value = "删除系统菜单")
	@PostMapping(value = "/deleteSmsSystemMenu")
	public Result deleteSmsSystemMenu(@RequestBody SmsSystemMenuDTO smsSystemMenuDTO) {
	    return smsSystemMenuService.deleteSmsSystemMenu(smsSystemMenuDTO);
	}
	
	@ApiOperation(value = "获取用户权限菜单列表",response=SmsSystemMenu.class)
	@PostMapping(value = "/getSmsUserMenuList")
	public Result getSmsUserMenuList(HttpServletRequest request) {
		HttpSession session=request.getSession();
		SmsUser user=(SmsUser)session.getAttribute(SessionKeys.ACCOUNT);
	    return smsSystemMenuService.getSmsUserMenuList(user.getUserId());
	}
}
